{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Sample Hangul RNN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Packages Imported\n"
     ]
    }
   ],
   "source": [
    "# -*- coding: utf-8 -*-\n",
    "# Import Packages\n",
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "import collections\n",
    "import string\n",
    "import argparse\n",
    "import time\n",
    "import os\n",
    "from six.moves import cPickle\n",
    "from TextLoader import *\n",
    "from Hangulpy import *\n",
    "print (\"Packages Imported\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load dataset using TextLoader"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loading preprocessed files\n",
      "type of 'data_loader' is <type 'dict'>, length is 76\n",
      "\n",
      "\n",
      "data_loader.vocab looks like \n",
      "{u'_': 69, u'6': 59, u':': 57, u'\\n': 19, u'4': 67, u'5': 63, u'>': 75, u'!': 52, u' ': 1, u'\"': 28, u'\\u1d25': 0, u\"'\": 49, u')': 46, u'(': 45, u'-': 65, u',': 27, u'.': 24, u'\\u3131': 7, u'0': 73, u'\\u3133': 60, u'\\u3132': 29, u'\\u3135': 50, u'\\u3134': 4, u'\\u3137': 13, u'\\u3136': 44, u'\\u3139': 5, u'\\u3138': 32, u'\\u313b': 55, u'\\u313a': 48, u'\\u313c': 54, u'?': 41, u'3': 66, u'\\u3141': 12, u'\\u3140': 51, u'\\u3143': 47, u'\\u3142': 17, u'\\u3145': 10, u'\\u3144': 43, u'\\u3147': 2, u'\\u3146': 22, u'\\u3149': 40, u'\\u3148': 15, u'\\u314b': 42, u'\\u314a': 23, u'\\u314d': 31, u'\\u314c': 30, u'\\u314f': 3, u'\\u314e': 14, u'\\u3151': 34, u'\\u3150': 21, u'\\u3153': 11, u'\\u3152': 74, u'\\u3155': 18, u'\\u3154': 20, u'\\u3157': 9, u'\\u3156': 39, u'\\u3159': 53, u'\\u3158': 26, u'\\u315b': 38, u'\\u315a': 33, u'\\u315d': 36, u'\\u315c': 16, u'\\u315f': 35, u'\\u315e': 61, u'\\u3161': 8, u'\\u3160': 37, u'\\u3163': 6, u'\\u3162': 25, u'\\x1a': 72, u'9': 64, u'7': 71, u'2': 62, u'1': 58, u'\\u313f': 56, u'\\u313e': 70, u'8': 68} \n",
      "\n",
      "\n",
      "type of 'data_loader.chars' is <type 'tuple'>, length is 76\n",
      "\n",
      "\n",
      "data_loader.chars looks like \n",
      "(u'\\u1d25', u' ', u'\\u3147', u'\\u314f', u'\\u3134', u'\\u3139', u'\\u3163', u'\\u3131', u'\\u3161', u'\\u3157', u'\\u3145', u'\\u3153', u'\\u3141', u'\\u3137', u'\\u314e', u'\\u3148', u'\\u315c', u'\\u3142', u'\\u3155', u'\\n', u'\\u3154', u'\\u3150', u'\\u3146', u'\\u314a', u'.', u'\\u3162', u'\\u3158', u',', u'\"', u'\\u3132', u'\\u314c', u'\\u314d', u'\\u3138', u'\\u315a', u'\\u3151', u'\\u315f', u'\\u315d', u'\\u3160', u'\\u315b', u'\\u3156', u'\\u3149', u'?', u'\\u314b', u'\\u3144', u'\\u3136', u'(', u')', u'\\u3143', u'\\u313a', u\"'\", u'\\u3135', u'\\u3140', u'!', u'\\u3159', u'\\u313c', u'\\u313b', u'\\u313f', u':', u'1', u'6', u'\\u3133', u'\\u315e', u'2', u'5', u'9', u'-', u'3', u'4', u'8', u'_', u'\\u313e', u'7', u'\\x1a', u'0', u'\\u3152', u'>') \n"
     ]
    }
   ],
   "source": [
    "data_dir    = \"data/nine_dreams\"\n",
    "batch_size  = 50\n",
    "seq_length  = 50\n",
    "data_loader = TextLoader(data_dir, batch_size, seq_length)\n",
    "# This makes \"vocab.pkl\" and \"data.npy\" in \"data/nine_dreams\"   \n",
    "#  from \"data/nine_dreams/input.txt\" \n",
    "vocab_size = data_loader.vocab_size\n",
    "vocab = data_loader.vocab\n",
    "chars = data_loader.chars\n",
    "print ( \"type of 'data_loader' is %s, length is %d\" \n",
    "       % (type(data_loader.vocab), len(data_loader.vocab)) )\n",
    "print ( \"\\n\" )\n",
    "print (\"data_loader.vocab looks like \\n%s \" %\n",
    "       (data_loader.vocab))\n",
    "print ( \"\\n\" )\n",
    "print ( \"type of 'data_loader.chars' is %s, length is %d\" \n",
    "       % (type(data_loader.chars), len(data_loader.chars)) )\n",
    "print ( \"\\n\" )\n",
    "print (\"data_loader.chars looks like \\n%s \" % (data_loader.chars,))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Define Network"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Network Ready\n"
     ]
    }
   ],
   "source": [
    "rnn_size   = 512\n",
    "num_layers = 3\n",
    "grad_clip  = 5.\n",
    "\n",
    "_batch_size = 1\n",
    "_seq_length = 1\n",
    "\n",
    "vocab_size = data_loader.vocab_size\n",
    "\n",
    "with tf.device(\"/cpu:0\"):\n",
    "    # Select RNN Cell\n",
    "    unitcell = tf.nn.rnn_cell.BasicLSTMCell(rnn_size)\n",
    "    cell = tf.nn.rnn_cell.MultiRNNCell([unitcell] * num_layers)\n",
    "    # Set paths to the graph \n",
    "    input_data = tf.placeholder(tf.int32, [_batch_size, _seq_length])\n",
    "    targets    = tf.placeholder(tf.int32, [_batch_size, _seq_length])\n",
    "    initial_state = cell.zero_state(_batch_size, tf.float32)\n",
    "\n",
    "    # Set Network\n",
    "    with tf.variable_scope('rnnlm'):\n",
    "        softmax_w = tf.get_variable(\"softmax_w\", [rnn_size, vocab_size])\n",
    "        softmax_b = tf.get_variable(\"softmax_b\", [vocab_size])\n",
    "        with tf.device(\"/cpu:0\"):\n",
    "            embedding = tf.get_variable(\"embedding\", [vocab_size, rnn_size])\n",
    "            inputs = tf.split(1, _seq_length, tf.nn.embedding_lookup(embedding, input_data))\n",
    "            inputs = [tf.squeeze(input_, [1]) for input_ in inputs]\n",
    "            \n",
    "    # Loop function for seq2seq\n",
    "    def loop(prev, _):\n",
    "        prev = tf.nn.xw_plus_b(prev, softmax_w, softmax_b)\n",
    "        prev_symbol = tf.stop_gradient(tf.argmax(prev, 1))\n",
    "        return tf.nn.embedding_lookup(embedding, prev_symbol)\n",
    "    # Output of RNN \n",
    "    outputs, last_state = tf.nn.seq2seq.rnn_decoder(inputs, initial_state\n",
    "                                , cell, loop_function=None, scope='rnnlm')\n",
    "    output = tf.reshape(tf.concat(1, outputs), [-1, rnn_size])\n",
    "    logits = tf.nn.xw_plus_b(output, softmax_w, softmax_b)\n",
    "    # Next word probability \n",
    "    probs = tf.nn.softmax(logits)\n",
    "    # Define LOSS\n",
    "    loss = tf.nn.seq2seq.sequence_loss_by_example([logits], # Input\n",
    "        [tf.reshape(targets, [-1])], # Target\n",
    "        [tf.ones([_batch_size * _seq_length])], # Weight \n",
    "        vocab_size)\n",
    "    # Define Optimizer\n",
    "    cost = tf.reduce_sum(loss) / _batch_size / _seq_length\n",
    "    final_state = last_state\n",
    "    lr = tf.Variable(0.0, trainable=False)\n",
    "    tvars = tf.trainable_variables()\n",
    "    grads, _ = tf.clip_by_global_norm(tf.gradients(cost, tvars), grad_clip)\n",
    "    _optm = tf.train.AdamOptimizer(lr)\n",
    "    optm = _optm.apply_gradients(zip(grads, tvars))\n",
    "\n",
    "print (\"Network Ready\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sampling function done.\n"
     ]
    }
   ],
   "source": [
    "# Sample ! \n",
    "def sample( sess, chars, vocab, __probs, num=200, prime=u'ㅇㅗᴥㄴㅡㄹᴥ '):\n",
    "    state = sess.run(cell.zero_state(1, tf.float32))\n",
    "    _probs = __probs\n",
    "    prime = list(prime)\n",
    "    for char in prime[:-1]:\n",
    "        x = np.zeros((1, 1))\n",
    "        x[0, 0] = vocab[char]\n",
    "        feed = {input_data: x, initial_state:state}\n",
    "        [state] = sess.run([final_state], feed)\n",
    "\n",
    "    def weighted_pick(weights):\n",
    "        weights = weights / np.sum(weights) \n",
    "        t = np.cumsum(weights)\n",
    "        s = np.sum(weights)\n",
    "        return(int(np.searchsorted(t, np.random.rand(1)*s)))\n",
    "\n",
    "    ret = prime\n",
    "    char = prime[-1]\n",
    "    for n in range(num):\n",
    "        x = np.zeros((1, 1))\n",
    "        x[0, 0] = vocab[char]\n",
    "        feed = {input_data: x, initial_state:state}\n",
    "        [_probsval, state] = sess.run([_probs, final_state], feed)\n",
    "        p = _probsval[0]\n",
    "        sample = int(np.random.choice(len(p), p=p))\n",
    "        # sample = weighted_pick(p)\n",
    "        # sample = np.argmax(p)\n",
    "        pred = chars[sample]\n",
    "        ret += pred\n",
    "        char = pred\n",
    "    return ret\n",
    "print (\"sampling function done.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Sample"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Prime Text : 누구  => ㄴㅜᴥㄱㅜᴥ \n",
      "data/nine_dreams/model.ckpt-99000\n",
      "SAMPLED TEXT = [u'\\u3134', u'\\u315c', u'\\u1d25', u'\\u3131', u'\\u315c', u'\\u1d25', u' ', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3139', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3145', u'\\u3153', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3131', u'\\u3153', u'\\u3145', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3157', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u'\"', u'\\n', u' ', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3145', u'\\u3153', u'\\u1d25', u' ', u'\\u3145', u'\\u3153', u'\\u1d25', u'\\u3147', u'\\u315c', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u3146', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u' ', u'\\n', u' ', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3137', u'\\u3150', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u3142', u'\\u1d25', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3147', u'\\u3160', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3137', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3148', u'\\u3154', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3134', u'\\u3161', u'\\u3134', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u3161', u'\\u1d25', u' ', u'\\u3147', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3141', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u315c', u'\\u3134', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u3146', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u' ', u'\\n', u' ', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3163', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u314f', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u1d25', u' ', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3134', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u3157', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\n', u'\\u3142', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3150', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u315c', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u3146', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u' ', u'\\n', u' ', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3137', u'\\u3150', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u3142', u'\\u1d25', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3147', u'\\u3160', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3148', u'\\u3154', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3148', u'\\u3154', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3147', u'\\u3160', u'\\u1d25', u'\\u3134', u'\\u3161', u'\\u3134', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3141', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3163', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u314f', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u1d25', u' ', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u314f', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3147', u'\\u1d25', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3155', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\n', u'\\u3142', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3150', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u315c', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u3146', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u' ', u'\\n', u' ', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3137', u'\\u3150', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u3142', u'\\u1d25', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3147', u'\\u3160', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3148', u'\\u3154', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3163', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u314f', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u1d25', u' ', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3134', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u3157', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\n', u'\\u3142', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3150', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u315c', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u3146', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u' ', u'\\n', u' ', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3147', u'\\u3154', u'\\u1d25', u' ', u'\\u3137', u'\\u3150', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u3142', u'\\u1d25', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3147', u'\\u3160', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3163', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u3146', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u3157', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u314e', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3155', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3134', u'\\u1d25', u' ', u'\\u3131', u'\\u3153', u'\\u3145', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u3144', u'\\u1d25', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3147', u'\\u3157', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3131', u'\\u3161', u'\\u1d25', u' ', u'\\u3147', u'\\u3155', u'\\u1d25', u'\\u3131', u'\\u3158', u'\\u3134', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u3144', u'\\u1d25', u'\\u3134', u'\\u3161', u'\\u3134', u'\\u1d25', u' ', u'\\u3131', u'\\u3153', u'\\u3145', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u1d25', u' ', u'\\u314e', u'\\u314f', u'\\u1d25', u'\\u3134', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\n', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u315c', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u3146', u'\\u1d25', u'\\u3137', u'\\u314f', u'\\u1d25', u'.', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3147', u'\\u3157', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u3157', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u1d25', u'\\u3134', u'\\u3163', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u' ', u'\\u3141', u'\\u314f', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3137', u'\\u1d25', u'\\u3131', u'\\u3157', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u1d25', u'\\u3131', u'\\u3163', u'\\u1d25', u'\\u3139', u'\\u3161', u'\\u3139', u'\\u1d25', u',', u' ', u'\\n', u' ', u' ', u'\"', u'\\u3145', u'\\u3157', u'\\u1d25', u'\\u3148', u'\\u3153', u'\\u1d25', u'\\u3131', u'\\u314f', u'\\u1d25', u' ', u'\\u3147', u'\\u3153', u'\\u1d25', u'\\u3149', u'\\u3163', u'\\u1d25', u' ', u'\\u3145', u'\\u314f', u'\\u1d25', u'\\u3139', u'\\u314f', u'\\u3141', u'\\u1d25', u'\\u3147', u'\\u3161', u'\\u3139', u'\\u1d25', u' ', u'\\u3137', u'\\u3161', u'\\u3139', u'\\u1d25', u'\\u3147', u'\\u3153', u'\\u1d25', u' ', u'\\u3131', u'\\u314f', u'\\u1d25', u'\\u3145', u'\\u3163', u'\\u1d25', u'\\u3131']\n",
      "\n",
      "-- RESULT --\n",
      "누구 소리에 서 있을 것이로다.\"\n",
      "  이어서 서울에 들어가니 어찌 이 말을 듣고 있으니 이 말을 듣고 있으니 이 말을 듣고 있었다. \n",
      "  이에 대답하기를, \n",
      "  \"소유가 다시 이르기를, \n",
      "  \"이제 이에 이르기를, \n",
      "  \"소저가 어찌 이르기를, \n",
      "  \"소저는 이 말을 듣고 이르기를, \n",
      "  \"소저가 어찌 사람을 들어 가서 그 아름다운 일이었다. \n",
      "  이 말에 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"소저가 어찌 사람을 들으니 이 말을 듣고 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"소저가 어찌 사람을 들어 가시가 아니라 하오니 이 일은 이 몸이 어찌 가을을 \n",
      "보내어 이름을 이루고 있었다. \n",
      "  이에 대답하기를, \n",
      "  \"소유가 이르기를, \n",
      "  \"이제 사람이 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"이제 이에 이르기를, \n",
      "  \"소유는 이미 사람을 들으니 이 말을 듣고 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"소저가 어찌 사람을 들어 가시가 아니라 하오니 이 아니 어찌 이를 사람을 사랑하여 이 일을 \n",
      "보내어 이름을 이루고 있었다. \n",
      "  이에 대답하기를, \n",
      "  \"소유가 이르기를, \n",
      "  \"이제 사람이 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"소저가 어찌 사람을 들어 가시가 아니라 하오니 이 일은 이 몸이 어찌 가을을 \n",
      "보내어 이름을 이루고 있었다. \n",
      "  이에 대답하기를, \n",
      "  \"소유가 이름을 들어 가시가 있으니 이 몸이 어찌 가히 여기를 들은 것이 없사오니 어찌 그 여관이 없는 것이라 하나 이 이름을 \n",
      "이루었다. \n",
      "  \"이 말을 들어 오르니 이 몸이 어찌 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"소저가 어찌 사람을 들으니 이 말을 듣고 이르기를, \n",
      "  \"소저가 이르기를, \n",
      "  \"소저가 어찌 사람을 들어 가시\n"
     ]
    }
   ],
   "source": [
    "save_dir = 'data/nine_dreams'\n",
    "prime = decompose_text(u\"누구 \")\n",
    "\n",
    "print (\"Prime Text : %s => %s\" % (automata(prime), \"\".join(prime)))\n",
    "n = 2000\n",
    "\n",
    "sess = tf.Session()\n",
    "sess.run(tf.initialize_all_variables())\n",
    "saver = tf.train.Saver(tf.all_variables())\n",
    "ckpt = tf.train.get_checkpoint_state(save_dir)\n",
    "\n",
    "# load_name = u'data/nine_dreams/model.ckpt-0'\n",
    "load_name = u'data/nine_dreams/model.ckpt-99000'\n",
    "\n",
    "print (load_name)\n",
    "\n",
    "if ckpt and ckpt.model_checkpoint_path:\n",
    "    saver.restore(sess, load_name)\n",
    "    sampled_text = sample(sess, chars, vocab, probs, n, prime)\n",
    "    #print (\"\")\n",
    "    print (u\"SAMPLED TEXT = %s\" % sampled_text)\n",
    "    print (\"\")\n",
    "    print (\"-- RESULT --\")\n",
    "    print (automata(\"\".join(sampled_text)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
